package org.grayrabbit.cloud.core.command;

import org.grayrabbit.cloud.core.biz.BizArgument;
import org.grayrabbit.cloud.core.biz.BizUtility;
import org.grayrabbit.cloud.core.module.ModuleException;
import org.grayrabbit.cloud.core.module.NoSuchModuleException;
import org.grayrabbit.cloud.core.rpc.Argument;
import org.grayrabbit.cloud.core.rpc.Result;

public abstract class AbstractCommand implements Command<Result> {
	protected BizArgument argument;

	public AbstractCommand() {
	}

	protected AbstractCommand(BizArgument argument) {
		construct(argument);
	}

	public void construct(BizArgument argument) {
		this.argument = argument;
	}
	


	public BizArgument getArgument() {
		return argument;
	}

	public Result submit(String module,Argument arg,boolean server)
			throws CommandException {
		try {
			return BizUtility.submit(module, arg,server);
		} catch (NoSuchModuleException e) {
			throw new CommandException(e);
		} catch (ModuleException e) {
			throw new CommandException(e);
		}
	}
}
